package org.csu.mypetstore.service;

import org.csu.mypetstore.domain.Account;
import org.csu.mypetstore.persistence.AccountMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AccountService {
    @Autowired
    private AccountMapper accountMapper;

    public List<Account> getAccountList() {
        return accountMapper.getAccountList();
    }

    public Account getAccountByUserId(String userid) {
        return accountMapper.getAccountByUserId(userid);
    }

    public void updateAccount(Account account) {
        accountMapper.updateAccount(account);
        if (account.getPassword() != null && account.getPassword().length()>0) {
            accountMapper.updateSignon(account);
        }
    }
}
